/*   1:    */ package com.atomikos.beans;
/*   2:    */ 
/*   3:    */ import java.beans.IndexedPropertyDescriptor;
/*   4:    */ import java.lang.reflect.Method;
/*   5:    */ 
/*   6:    */ class IndexedPropertyImp
/*   7:    */   extends PropertyImp
/*   8:    */   implements IndexedProperty
/*   9:    */ {
/*  10:    */   private IndexedPropertyDescriptor descriptor_;
/*  11:    */   
/*  12:    */   IndexedPropertyImp(Object bean, IndexedPropertyDescriptor descriptor)
/*  13:    */     throws PropertyException
/*  14:    */   {
/*  15: 52 */     super(bean, descriptor);
/*  16: 53 */     this.descriptor_ = descriptor;
/*  17:    */   }
/*  18:    */   
/*  19:    */   public Object getValue(int i)
/*  20:    */     throws PropertyException
/*  21:    */   {
/*  22: 63 */     Object ret = null;
/*  23:    */     try
/*  24:    */     {
/*  25: 66 */       Method m = this.descriptor_.getIndexedReadMethod();
/*  26: 67 */       Integer index = new Integer(i);
/*  27: 68 */       Object[] args = new Object[1];
/*  28: 69 */       args[0] = index;
/*  29: 70 */       ret = m.invoke(getBean(), args);
/*  30:    */     }
/*  31:    */     catch (Exception e)
/*  32:    */     {
/*  33: 73 */       throw new PropertyException("Error getting property", e);
/*  34:    */     }
/*  35: 76 */     return ret;
/*  36:    */   }
/*  37:    */   
/*  38:    */   public boolean isIndexReadOnly()
/*  39:    */   {
/*  40: 85 */     return this.descriptor_.getIndexedWriteMethod() == null;
/*  41:    */   }
/*  42:    */   
/*  43:    */   public void setValue(int i, Object arg)
/*  44:    */     throws ReadOnlyException, PropertyException
/*  45:    */   {
/*  46: 95 */     if (isIndexReadOnly()) {
/*  47: 96 */       throw new ReadOnlyException("Property is readonly");
/*  48:    */     }
/*  49:    */     try
/*  50:    */     {
/*  51:100 */       Object[] args = new Object[2];
/*  52:101 */       args[0] = new Integer(i);
/*  53:102 */       args[1] = arg;
/*  54:103 */       Method method = this.descriptor_.getIndexedWriteMethod();
/*  55:104 */       method.invoke(getBean(), args);
/*  56:    */     }
/*  57:    */     catch (Exception e)
/*  58:    */     {
/*  59:107 */       throw new PropertyException("Error in setting value", e);
/*  60:    */     }
/*  61:    */   }
/*  62:    */   
/*  63:    */   public Class getIndexedType()
/*  64:    */   {
/*  65:117 */     return this.descriptor_.getIndexedPropertyType();
/*  66:    */   }
/*  67:    */   
/*  68:    */   public IndexedProperty getIndexedProperty()
/*  69:    */   {
/*  70:126 */     return this;
/*  71:    */   }
/*  72:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\atomikos-util\3.7.0\atomikos-util-3.7.0.jar
 * Qualified Name:     com.atomikos.beans.IndexedPropertyImp
 * JD-Core Version:    0.7.0.1
 */